<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>J</title>
</head>
<body>
    <Script>
        var str = "Hello World";
        console.log(str.length);
        console.log(str.toUpperCase());
        console.log(str.toLowerCase());
        console.log(str.charAt(0));
        console.log(str.charCodeAt(0));
        console.log(str.indexOf('o'));
        console.log(str.lastIndexOf('o'));
        console.log(str.substring(0,5));
        //for-of
        for (var i of str) {
            console.log(i);
        }
    </Script>
    <script>
        var user = {
            name: '张三',
            age: 18,
            sex: '男',
            show: function() {
                console.log(this.name + ',' + this.age + ',' + this.sex);
            },
            eat: function () {
                console.log(this.name + '吃吃吃');
            },
            sleep: function () {
                console.log(this.name + '睡觉zzZzz');
                return 'zzz';
            }
        }
        console.log(user);
        console.log(user.name);
        user.show();
        user.eat();
        user.sleep();
        console.log(user.sleep());
        
        //for-in
        for (var key in user) {
            console.log(key + ':' + user[key]);
        }
        console.log('----------');
        for (var key in user) {
            console.log(key + ':' + user.key);//访问对象的key属性，这里key是字面量属性名
        }
    </script>
</body>
</html>